package data

import (
	goods_pb "mxshop/api/goods/v1"
	inventory_pb "mxshop/api/inventory/v1"
	user_pb "mxshop/api/user/v1"
	IGoods "mxshop/app/mxshop_api/api/internal/data/goods"
	dataGoods "mxshop/app/mxshop_api/api/internal/data/goods/v2"
	IInv "mxshop/app/mxshop_api/api/internal/data/inv"
	dataInv "mxshop/app/mxshop_api/api/internal/data/inv/v2"
	IUser "mxshop/app/mxshop_api/api/internal/data/user"
	dataUser "mxshop/app/mxshop_api/api/internal/data/user/v2"
)

type DataFactory interface {
	User() IUser.UserData
	Goods() IGoods.GoodsData
	Inv() IInv.InventoryData
	//Goods() goodsSrv.GoodsData
}

type data struct {
	UserClient  user_pb.UserClient
	GoodsClient goods_pb.GoodsClient
	InvClient   inventory_pb.InventoryClient
}

func (d *data) User() IUser.UserData {
	return dataUser.NewUser(d.UserClient)
}

func (d *data) Goods() IGoods.GoodsData {
	return dataGoods.NewGoods(d.GoodsClient)
}

func (d *data) Inv() IInv.InventoryData {
	return dataInv.NewInv(d.InvClient)
}

func NewData(user user_pb.UserClient, goods goods_pb.GoodsClient, inv inventory_pb.InventoryClient) DataFactory {
	return &data{
		UserClient:  user,
		GoodsClient: goods,
		InvClient:   inv,
	}
}
